package controllers.api;

import java.io.IOException;

import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;

import play.mvc.Controller;

public class API extends Controller {
	
	private static ObjectMapper mapper = new ObjectMapper();
	static {
		mapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);
	}
	
	protected static void json(Object object){
    	try {
    		renderJSON(mapper.writeValueAsString(object));
    	} catch (IOException e) {
			json(e.getMessage());
		}
    }
}
